<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  <title>Powers: <%= controller.action_name %></title>
  <%= stylesheet_link_tag 'scaffold' %>
  <style type="text/css">
   html {height:100%;}
   body {height:100%; margin:0; padding:0;}
   h2 {font-family:arial;}
   #bg {position:fixed; top:0; left:0; width:100%; height:100%;}
   #content {position:relative; z-index:1;}
   #transvalues {position:relative; z-index:2;}
   #timelabels {position:relative; z-index:3;}
   #logo {position:relative; z-index:4;}
  </style> 
</head>
<body>
<div id="bg"></div>
<div id="logo" style="position:absolute; left:30px; top:30px;"><IMG src="images/logo.jpg" alt="Southface"></div>
<div id="transvalues" style="position:absolute; left:25px; top:190px;">
  <% midnight = (Time.now - (Time.now.hour*60*60) - (Time.now.min*60) - (Time.now.sec)).gmtime %>
  <% yday = Power.find(:first, :conditions=>["created_at > :cutoff", {:cutoff => midnight}]) %>
  <% tday = Power.find(:first, :conditions=>["created_at > :cutoff", {:cutoff => 30.minutes.ago}]) %>
  <% usage = 0 if ! (tday and yday) %>
  <% usage = (tday.value - yday.value)  / 33333.0 if (tday and yday) %>
  <TABLE border=0><FONT face="arial">
    <TR><TD><h2><%= "%0.1f" % usage%> kWh</h1></TD></TR>
    <TR><TD><h2>$<%= "%0.2f" % (usage * 0.12) %></h1></TD></TR>
    <TR><TD><h2><%= "%0.1f" % (usage * 0.666) %> lbs. of coal</h1></TD></TR></FONT>
  </TABLE>
</div>

<p style="color: green"><%= flash[:notice] %></p>
<%= yield  %>
</body>
</html>
